#define _CRT_SECURE_NO_WARNINGS 1

#include "string.h"

void test_string1()
{
	lwl::string s1("hello world");
	cout << s1 << endl;
	cout << s1.c_str() << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;

	lwl::string s2(s1);
	cout << s2 << endl;
	cout << s2.c_str() << endl;
	cout << s2.size() << endl;
	cout << s2.capacity() << endl;

	s2 += " lwl";
	cout << s2 << endl;
	cout << s2.c_str() << endl;
	cout << s2.size() << endl;
	cout << s2.capacity() << endl;

	size_t i = 0;
	for (i = 0; i < s2.size(); i++)
	{
		cout << s2[i] << " ";
	}

	cout << endl;

	for (auto e : s2)
	{
		cout << e << " ";
	}

	cout << endl;

	lwl::string::iterator it = s2.begin();
	while (it != s2.end())
	{
		cout << *it << " ";
		++it;
	}

	cout << endl;
}


void test_string2()
{
	lwl::string s1("hello world");
	s1.push_back('&');
	cout << s1.c_str() << endl; // hello world&


	s1.append("lwl666");
	cout << s1.c_str() << endl; // hello world&lwl666


	lwl::string s2 = "liuwenlong";
	s2 += "666666";
	cout << s2 << endl; // liuwenlong666666

	s2.insert(5, '&');
	cout << s2 << endl; // liuwe&nlong666666

	s2.insert(8, "***");
	cout << s2 << endl; // liuwe&nl***ong666666

	s2.insert(0, '!');
	cout << s2 << endl; // !liuwe&nl***ong666666

	s2.erase(6, 6);
	cout << s2 << endl; // !liuweong666666
}

int main()
{
	test_string1();

	return 0;
}